<template>
  <div id="app">
    <h1>vuex简介</h1>
    <div class="text">userInfo：{{userInfo}}</div>
    <div class="btn" @click="mutationsBtn">{{ou.userName}}</div>
    <div class="btn" @click="actionBtn">action</div>
    <router-view></router-view>
  </div>
</template>

<script type="text/ecmascript-6">
import { mapGetters, mapMutations, mapState, mapActions } from 'vuex'
export default {
  name: 'App',
  computed: {
    ...mapGetters([
      'userInfo',
      'userName'
    ]),
    ...mapState([
      'ou'
    ])
  },
  methods: {
    mutationsBtn () {
      this.SET_USERINFO('我是mutations派送的数据')
    },
    actionBtn () {
      this.getName('我是action派送的数据')
    },
    ...mapMutations({
      getName: 'ou/SET_USERNAME'
    }),
    ...mapActions([
      'setUserInfo'
    ])
  }
}
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.btn {
  padding: 10px;
  margin-top: 10px;
  border: 1px solid #dedede;
}
</style>
